import axios from 'axios'
import { baseURL } from '../baseurl'


export default function downLoadFile() {
    return axios.get(baseURL + '/team/downloadMax',{
    // return axios.get(baseURL + '/team/downloadMax',JSON.stringify(urls),{
        headers: {
            'Content-type': 'application/json;charset=utf8'
        },
            responseType: 'blob'
        }).then(res => {
        console.log(res)
        let blob = new Blob([res.data], {type: 'application/zip'})
        let url = window.URL.createObjectURL(blob)
        const link = document.createElement('a') // 创建a标签
        link.href = url
        link.setAttribute("download", "所有文件")
        link.click()
        
        URL.revokeObjectURL(url) // 释放内存
    }).catch(err => {
        console.log(err)
    })
}

// export default function downLoadFile(urls) {
//     return axios.post(baseURL + '/team/downloadAll',JSON.stringify(urls),{
//         headers: {
//             'Content-type': 'application/json;charset=utf8'
//         }
//     },
//     {response:'blob'}).then(res => {
//         //多文件下载，通过循环下载，有几个url就下载几次
//         for(let i =0;i<urls.length;i++)
//         {
//             let a = document.createElement('a');
 
//             let blob = new Blob([res.data], {type: "application/vnd.ms-excel"})
                  
//             let objectUrl = URL.createObjectURL(blob)

//             a.setAttribute("href",objectUrl)
//             a.setAttribute("download", urls[i])
//             a.click()
//         }
//     })

// }